package com.ruoyi.zikao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zikao.domain.ZikaoPreEducation;
import com.ruoyi.zikao.service.IZikaoPreEducationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 考前学历Controller
 * 
 * @author ruoyi
 * @date 2025-07-14
 */
@Api(tags = "自考-前置学历管理")
@RestController
@RequestMapping("/zikao/education")
public class ZikaoPreEducationController extends BaseController
{
    @Autowired
    private IZikaoPreEducationService zikaoPreEducationService;

    /**
     * 查询考前学历列表
     */
    //@PreAuthorize("@ss.hasPermi('zikao:education:list')")
    @GetMapping("/list")
        @ApiOperation("自考前置学历管理 - 分页查询列表")
    public TableDataInfo list(ZikaoPreEducation zikaoPreEducation)
    {
        startPage();
        List<ZikaoPreEducation> list = zikaoPreEducationService.selectZikaoPreEducationList(zikaoPreEducation);
        return getDataTable(list);
    }

    @GetMapping("/all")
        @ApiOperation("自考前置学历管理 - all")
    public AjaxResult all()
    {
        return success(zikaoPreEducationService.selectZikaoPreEducationAll());
    }
    /**
     * 导出考前学历列表
     */
    @PreAuthorize("@ss.hasPermi('zikao:education:export')")
    @Log(title = "考前学历", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
        @ApiOperation("自考前置学历管理 - 导出数据")
    public void export(HttpServletResponse response, ZikaoPreEducation zikaoPreEducation)
    {
        List<ZikaoPreEducation> list = zikaoPreEducationService.selectZikaoPreEducationList(zikaoPreEducation);
        ExcelUtil<ZikaoPreEducation> util = new ExcelUtil<ZikaoPreEducation>(ZikaoPreEducation.class);
        util.exportExcel(response, list, "考前学历数据");
    }

    /**
     * 获取考前学历详细信息
     */
    //@PreAuthorize("@ss.hasPermi('zikao:education:query')")
    @GetMapping(value = "/{id}")
        @ApiOperation("自考前置学历管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zikaoPreEducationService.selectZikaoPreEducationById(id));
    }

    /**
     * 新增考前学历
     */
    //@PreAuthorize("@ss.hasPermi('zikao:education:add')")
    @Log(title = "考前学历", businessType = BusinessType.INSERT)
    @PostMapping
        @ApiOperation("自考前置学历管理 - 新增数据")
    public AjaxResult add(@RequestBody ZikaoPreEducation zikaoPreEducation)
    {
        return toAjax(zikaoPreEducationService.insertZikaoPreEducation(zikaoPreEducation));
    }

    /**
     * 修改考前学历
     */
    //@PreAuthorize("@ss.hasPermi('zikao:education:edit')")
    @Log(title = "考前学历", businessType = BusinessType.UPDATE)
    @PutMapping
        @ApiOperation("自考前置学历管理 - 修改数据")
    public AjaxResult edit(@RequestBody ZikaoPreEducation zikaoPreEducation)
    {
        return toAjax(zikaoPreEducationService.updateZikaoPreEducation(zikaoPreEducation));
    }

    /**
     * 删除考前学历
     */
    //@PreAuthorize("@ss.hasPermi('zikao:education:remove')")
    @Log(title = "考前学历", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
        @ApiOperation("自考前置学历管理 - 删除数据")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zikaoPreEducationService.deleteZikaoPreEducationByIds(ids));
    }
}
